Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing compressor #34

Merged
merged 14 commits into from
Jan 11, 2024
Merged

Fixing compressor #34

merged 14 commits into from
Jan 11, 2024

Conversation

Mozoloa
Copy link
Contributor

@Mozoloa Mozoloa commented Jan 6, 2024

I've discovered that the compressor's ratio was behaving incorrectly. It was pretty much inversed in it's effect, a ratio of close to 50 was close to actually 1:1 in effect, same with close to 1 being actually close to infinity.

So I've redesigned the compressor to act in a more conventional way

I've tested it and so far it looks like it works alright, ratios are perfectly respected. More info in the code comments.

This might be app breaking for people that had implemented a hotfix on their end by reverse engineering the defective ratio tho.

@Mozoloa
Copy link
Contributor Author

Mozoloa commented Jan 6, 2024

I just added softknee function to the compressor as kneeWidth arg in dB, 0 for hard knee
Inspired by this

I've tested it and it seems to work well

el.compress(1, 100, -10, 100, 12, in, in);

image

el.compress(1, 100, -10, 4, 6, in, in);

image

el.compress(1, 100, -30, 10, 24, in, in);

image

Sorry for the cropped out axis, but everything seem in place from the values I can see

@nick-thompson
Copy link
Contributor

@Mozoloa fantastic PR thank you! A couple of quick changes if you don't mind:

  • Rebase against the develop branch. I cut canary releases from develop with new features/bug fixes and then promote to main once the canary is out for a few days
  • Let's introduce the soft-knee behavior as a new function el.skcompress or el.softcompress. Having both a hard and a soft option makes sense, and also this lets us avoid breaking the expected arguments to el.compress
  • Then let's keep el.compress as it was but add only the ratio fix there. You're right technically that might break existing code but it feels to me like it falls more in the category of a bugfix than a breaking change.

That sound ok? That feels to me like the right to navigate non-breaking changes and bug-fixes

@Mozoloa Mozoloa changed the base branch from main to develop January 7, 2024 19:30
@Mozoloa
Copy link
Contributor Author

Mozoloa commented Jan 9, 2024

All good

Copy link
Contributor

@nick-thompson nick-thompson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great @Mozoloa thank you again! Three more tiny things if you don't mind 🙏

@@ -44,22 +44,70 @@ export function compress(
xn: ElemNode,
): NodeRepr_t;

export function compress(
export function compress(a_, b_, c_, d_, e_, f_, g_?) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this was probably a bug leftover from me, but if you don't mind fixing it while we're here I'd appreciate it–

The type signature above doesn't present an optional props argument up front, so we can write this function signature here as

export function compress(atkMs, relMs, threshold, ratio, sidechain, xn)

and then skip the whole let children = (typeof stuff below it

* @param {Node} sidechain – sidechain signal to drive the compressor
* @param {Node} xn – input signal to filter
*/
export function skcompress(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do the same thing here, remove that props argument here in the type signature, and then below let's do

export function skcompress(atkMs, relMs, threshold, ratio, kneeWidth, sidechain, xn)

and skip the whole optional arg stuff

README.md Outdated
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/elemaudio/elementary/blob/main/LICENSE.md)
[![Discord Community](https://img.shields.io/discord/826071713426178078?label=Discord)](https://discord.gg/xSu9JjHwYc)
[![npm installs](https://img.shields.io/npm/dt/%40elemaudio/core?label=npm%20installs&color=%23f472b6)](https://www.npmjs.com/package/@elemaudio/core)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is my bad I think– would you mind dropping the changes to README here so that the PR only affects the compressor code? I'll fix up the README changes in a follow-up commit

@nick-thompson nick-thompson merged commit cffd665 into elemaudio:develop Jan 11, 2024
4 checks passed
@nick-thompson
Copy link
Contributor

Ok got it, this will roll out with elem v3.1.0. Thank you @Mozoloa !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants